var user_data = {},page_data = {},page_log={};
apiready = function () {
    var _$ = {};
    _$.config = {
        'debug': true,                                      //开启log
        'debugtools': true,                                  //开启开发插件
        'imgCache':false,                                    //是否开启图片缓存
        'hilight': true,                                     //高亮顶部toolbar
        'push': false,                                       //是否开启推送
        'wrapid': 'app_page_wrap',                          //用于包裹body中内容的委托dom的id
        'appname': "lizi",                                   //app的名称
        'appname_cn': "荔子",                                //app的名称
        'server': "",               //app的名称
        'imgpach': "http://lizi.haizizhu.com/attachment/",         //ajax的提交根地址
        'apiurl': "http://lizi.haizizhu.com/app/index.php?i=2&c=entry&m=grow",                //ajax的提交根地址
        'ajaxtype': 'POST',                                 //ajax提交的方式。
        'ajaxdatatype': 'json',                             //返回的数据格式。
        'ajaxtimeout': 6,                                   //ajax超时时间,单位秒。
        'ajaxdelay': 500,                                   //ajax请求的延迟发送时间,单位毫秒。
        'ajax_status_code': {
            'sucess': '200',                                //正常
            'unLogin': '301',                               //未登录
            'servererror': '500'                            //服务器错误
        },
        'msgTimeout': 3000,                                 //msg延迟关闭时间。
        'dataFrameName': 'root',                            //处理data的页面名称。
        'userDataName': 'appUserData',                      //本地存储的用户数据变量名。
        'api_login': 'Apinurse/login',                      //登录接口
        'api_register': 'Apinurse/register',                //注册接口
        'api_userread': 'Apinurse/is_login',                //判断登录
        'api_usersave': 'Apinurse/save_user',               //保存用户信息
        'api_imgupload': 'Apinurse/upload_image',           //上传图片
        'events': {}                                        //监听的页面动作
    }
    _$.language = {
        'default': '出错啦（x_x）请联系管理员.',
        'net': {
            'err0': '出错啦（x_x）请联系管理员.',
            'err1': '网络差，请稍后再试.',
            'err2': '无网络连接.'
        },
        'msg': {},
        'dataTest': {
            'undefined': '验证表达式不存在',
            'NULL': '验证方法调用不正确',
            'mobile': '请输入正确的手机号',
            'TEL': '电话号码不正确',
            'code': '请填写验证码',
            'pasword0': '密码格式不正确',
            'pasword1': '密码过短',
            'pasword2': '密码过长',
            'pasword3': '两次密码不一致',
            'pasword9': '请填写密码',
            'empty': '数据未填写',
            'email': '邮箱地址不正确',
            'date': '日期格式不正确',
            'year': '请正确填写年份',
            'month': '请正确填写月份',
            'day': '请正确填写日期',
            'number': '请填写数字',
            'subNumber': '请填写小数'
        },
        'dialog': {
            //弹窗提示文字
            'confirm': {
                'cont': '请确认操作!',
                'title': '提示',
                'button': ['确定', '取消']
            },
            'alert': {
                'cont': '完成!',
                'title': '提示',
                'button': '我知道了'
            },
            'msgInto': {
                'cont': '完成'
            }
        }
    }
    _$.tool = {
        //给一个随机临时的字符串id
        tempid: function (num) {//给一个随机ID
            var n = num || 8;
            var chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
            var res = "";
            for (var i = 0; i < n; i++) {
                var id = Math.ceil(Math.random() * 35);
                res += chars[id];
            }
            return 'ID_'+res;
        },
        md5: function md5(string) {
            function md5_RotateLeft(lValue, iShiftBits) {
                return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
            }
            function md5_AddUnsigned(lX, lY) {
                var lX4, lY4, lX8, lY8, lResult;
                lX8 = (lX & 0x80000000);
                lY8 = (lY & 0x80000000);
                lX4 = (lX & 0x40000000);
                lY4 = (lY & 0x40000000);
                lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
                if (lX4 & lY4) {
                    return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
                }
                if (lX4 | lY4) {
                    if (lResult & 0x40000000) {
                        return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
                    } else {
                        return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
                    }
                } else {
                    return (lResult ^ lX8 ^ lY8);
                }
            }
            function md5_F(x, y, z) {
                return (x & y) | ((~x) & z);
            }
            function md5_G(x, y, z) {
                return (x & z) | (y & (~z));
            }
            function md5_H(x, y, z) {
                return (x ^ y ^ z);
            }
            function md5_I(x, y, z) {
                return (y ^ (x | (~z)));
            }
            function md5_FF(a, b, c, d, x, s, ac) {
                a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_F(b, c, d), x), ac));
                return md5_AddUnsigned(md5_RotateLeft(a, s), b);
            };
            function md5_GG(a, b, c, d, x, s, ac) {
                a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_G(b, c, d), x), ac));
                return md5_AddUnsigned(md5_RotateLeft(a, s), b);
            };
            function md5_HH(a, b, c, d, x, s, ac) {
                a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_H(b, c, d), x), ac));
                return md5_AddUnsigned(md5_RotateLeft(a, s), b);
            };
            function md5_II(a, b, c, d, x, s, ac) {
                a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_I(b, c, d), x), ac));
                return md5_AddUnsigned(md5_RotateLeft(a, s), b);
            };
            function md5_ConvertToWordArray(string) {
                var lWordCount;
                var lMessageLength = string.length;
                var lNumberOfWords_temp1 = lMessageLength + 8;
                var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64;
                var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
                var lWordArray = Array(lNumberOfWords - 1);
                var lBytePosition = 0;
                var lByteCount = 0;
                while (lByteCount < lMessageLength) {
                    lWordCount = (lByteCount - (lByteCount % 4)) / 4;
                    lBytePosition = (lByteCount % 4) * 8;
                    lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
                    lByteCount++;
                }
                lWordCount = (lByteCount - (lByteCount % 4)) / 4;
                lBytePosition = (lByteCount % 4) * 8;
                lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
                lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
                lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
                return lWordArray;
            };
            function md5_WordToHex(lValue) {
                var WordToHexValue = "", WordToHexValue_temp = "", lByte, lCount;
                for (lCount = 0; lCount <= 3; lCount++) {
                    lByte = (lValue >>> (lCount * 8)) & 255;
                    WordToHexValue_temp = "0" + lByte.toString(16);
                    WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2);
                }
                return WordToHexValue;
            };
            function md5_Utf8Encode(string) {
                string = string.replace(/\r\n/g, "\n");
                var utftext = "";
                for (var n = 0; n < string.length; n++) {
                    var c = string.charCodeAt(n);
                    if (c < 128) {
                        utftext += String.fromCharCode(c);
                    } else if ((c > 127) && (c < 2048)) {
                        utftext += String.fromCharCode((c >> 6) | 192);
                        utftext += String.fromCharCode((c & 63) | 128);
                    } else {
                        utftext += String.fromCharCode((c >> 12) | 224);
                        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                        utftext += String.fromCharCode((c & 63) | 128);
                    }
                }
                return utftext;
            };
            var x = Array();
            var k, AA, BB, CC, DD, a, b, c, d;
            var S11 = 7, S12 = 12, S13 = 17, S14 = 22;
            var S21 = 5, S22 = 9, S23 = 14, S24 = 20;
            var S31 = 4, S32 = 11, S33 = 16, S34 = 23;
            var S41 = 6, S42 = 10, S43 = 15, S44 = 21;
            string = md5_Utf8Encode(string);
            x = md5_ConvertToWordArray(string);
            a = 0x67452301;
            b = 0xEFCDAB89;
            c = 0x98BADCFE;
            d = 0x10325476;
            for (k = 0; k < x.length; k += 16) {
                AA = a;
                BB = b;
                CC = c;
                DD = d;
                a = md5_FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
                d = md5_FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
                c = md5_FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
                b = md5_FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
                a = md5_FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
                d = md5_FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
                c = md5_FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
                b = md5_FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
                a = md5_FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
                d = md5_FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
                c = md5_FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
                b = md5_FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
                a = md5_FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
                d = md5_FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
                c = md5_FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
                b = md5_FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
                a = md5_GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
                d = md5_GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
                c = md5_GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
                b = md5_GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
                a = md5_GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
                d = md5_GG(d, a, b, c, x[k + 10], S22, 0x2441453);
                c = md5_GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
                b = md5_GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
                a = md5_GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
                d = md5_GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
                c = md5_GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
                b = md5_GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
                a = md5_GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
                d = md5_GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
                c = md5_GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
                b = md5_GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
                a = md5_HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
                d = md5_HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
                c = md5_HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
                b = md5_HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
                a = md5_HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
                d = md5_HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
                c = md5_HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
                b = md5_HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
                a = md5_HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
                d = md5_HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
                c = md5_HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
                b = md5_HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
                a = md5_HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
                d = md5_HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
                c = md5_HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
                b = md5_HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
                a = md5_II(a, b, c, d, x[k + 0], S41, 0xF4292244);
                d = md5_II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
                c = md5_II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
                b = md5_II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
                a = md5_II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
                d = md5_II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
                c = md5_II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
                b = md5_II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
                a = md5_II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
                d = md5_II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
                c = md5_II(c, d, a, b, x[k + 6], S43, 0xA3014314);
                b = md5_II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
                a = md5_II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
                d = md5_II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
                c = md5_II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
                b = md5_II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
                a = md5_AddUnsigned(a, AA);
                b = md5_AddUnsigned(b, BB);
                c = md5_AddUnsigned(c, CC);
                d = md5_AddUnsigned(d, DD);
            }
            return (md5_WordToHex(a) + md5_WordToHex(b) + md5_WordToHex(c) + md5_WordToHex(d)).toLowerCase();
        },
        SHA1: function (msg) {
            function rotate_left(n, s) {
                var t4 = (n << s) | (n >>> (32 - s));
                return t4;
            };
            function lsb_hex(val) {
                var str = "";
                var i;
                var vh;
                var vl;
                for (i = 0; i <= 6; i += 2) {
                    vh = (val >>> (i * 4 + 4)) & 0x0f;
                    vl = (val >>> (i * 4)) & 0x0f;
                    str += vh.toString(16) + vl.toString(16);
                }
                return str;
            };
            function cvt_hex(val) {
                var str = "";
                var i;
                var v;
                for (i = 7; i >= 0; i--) {
                    v = (val >>> (i * 4)) & 0x0f;
                    str += v.toString(16);
                }
                return str;
            };
            function Utf8Encode(string) {
                string = string.replace(/\r\n/g, "\n");
                var utftext = "";
                for (var n = 0; n < string.length; n++) {
                    var c = string.charCodeAt(n);
                    if (c < 128) {
                        utftext += String.fromCharCode(c);
                    }
                    else if ((c > 127) && (c < 2048)) {
                        utftext += String.fromCharCode((c >> 6) | 192);
                        utftext += String.fromCharCode((c & 63) | 128);
                    }
                    else {
                        utftext += String.fromCharCode((c >> 12) | 224);
                        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                        utftext += String.fromCharCode((c & 63) | 128);
                    }
                }
                return utftext;
            };
            var blockstart;
            var i, j;
            var W = new Array(80);
            var H0 = 0x67452301;
            var H1 = 0xEFCDAB89;
            var H2 = 0x98BADCFE;
            var H3 = 0x10325476;
            var H4 = 0xC3D2E1F0;
            var A, B, C, D, E;
            var temp;
            msg = Utf8Encode(msg);
            var msg_len = msg.length;
            var word_array = new Array();
            for (i = 0; i < msg_len - 3; i += 4) {
                j = msg.charCodeAt(i) << 24 | msg.charCodeAt(i + 1) << 16 |
                    msg.charCodeAt(i + 2) << 8 | msg.charCodeAt(i + 3);
                word_array.push(j);
            }
            switch (msg_len % 4) {
                case 0:
                    i = 0x080000000;
                    break;
                case 1:
                    i = msg.charCodeAt(msg_len - 1) << 24 | 0x0800000;
                    break;
                case 2:
                    i = msg.charCodeAt(msg_len - 2) << 24 | msg.charCodeAt(msg_len - 1) << 16 | 0x08000;
                    break;
                case 3:
                    i = msg.charCodeAt(msg_len - 3) << 24 | msg.charCodeAt(msg_len - 2) << 16 | msg.charCodeAt(msg_len - 1) << 8 | 0x80;
                    break;
            }
            word_array.push(i);
            while ((word_array.length % 16) != 14) word_array.push(0);
            word_array.push(msg_len >>> 29);
            word_array.push((msg_len << 3) & 0x0ffffffff);
            for (blockstart = 0; blockstart < word_array.length; blockstart += 16) {
                for (i = 0; i < 16; i++) W[i] = word_array[blockstart + i];
                for (i = 16; i <= 79; i++) W[i] = rotate_left(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
                A = H0;
                B = H1;
                C = H2;
                D = H3;
                E = H4;
                for (i = 0; i <= 19; i++) {
                    temp = (rotate_left(A, 5) + ((B & C) | (~B & D)) + E + W[i] + 0x5A827999) & 0x0ffffffff;
                    E = D;
                    D = C;
                    C = rotate_left(B, 30);
                    B = A;
                    A = temp;
                }
                for (i = 20; i <= 39; i++) {
                    temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff;
                    E = D;
                    D = C;
                    C = rotate_left(B, 30);
                    B = A;
                    A = temp;
                }
                for (i = 40; i <= 59; i++) {
                    temp = (rotate_left(A, 5) + ((B & C) | (B & D) | (C & D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff;
                    E = D;
                    D = C;
                    C = rotate_left(B, 30);
                    B = A;
                    A = temp;
                }
                for (i = 60; i <= 79; i++) {
                    temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff;
                    E = D;
                    D = C;
                    C = rotate_left(B, 30);
                    B = A;
                    A = temp;
                }
                H0 = (H0 + A) & 0x0ffffffff;
                H1 = (H1 + B) & 0x0ffffffff;
                H2 = (H2 + C) & 0x0ffffffff;
                H3 = (H3 + D) & 0x0ffffffff;
                H4 = (H4 + E) & 0x0ffffffff;
            }
            var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4);
            return temp.toLowerCase();
        },
        typeof: function (o) {
            /**
             * typeof("abc"); //string
             * typeof(true); //boolean
             * typeof(123); //number
             * typeof([]); //array
             * typeof({}); //object => json
             * typeof(function(){}); //function
             * typeof(new Date); //date
             * typeof(new RegExp); //regexp
             * typeof(Math); //math
             * typeof(null); //null
             **/
            var _t;
            return ((_t = typeof(o)) == "object" ? o == null && "null" || Object.prototype.toString.call(o).slice(8, -1) : _t).toLowerCase();
        },
        timeFormat: function (date, format) {
            /**
             * 对日期进行格式化，
             * @param date 要格式化的日期
             * @param format 进行格式化的模式字符串
             *     支持的模式字母有：
             *     y:年,
             *     M:年中的月份(1-12),
             *     d:月份中的天(1-31),
             *     h:小时(0-23),
             *     m:分(0-59),
             *     s:秒(0-59),
             *     S:毫秒(0-999),
             *     q:季度(1-4)
             * @return String
             */
            date = new Date(date);
            var map = {
                "M": date.getMonth() + 1, //月份
                "d": date.getDate(), //日
                "h": date.getHours(), //小时
                "m": date.getMinutes(), //分
                "s": date.getSeconds(), //秒
                "q": Math.floor((date.getMonth() + 3) / 3), //季度
                "S": date.getMilliseconds() //毫秒
            };
            format = format.replace(/([yMdhmsqS])+/g, function (all, t) {
                var v = map[t];
                if (v !== undefined) {
                    if (all.length > 1) {
                        v = '0' + v;
                        v = v.substr(v.length - 2);
                    }
                    return v;
                }
                else if (t === 'y') {
                    return (date.getFullYear() + '').substr(4 - all.length);
                }
                return all;
            });
            return format;
        },
        time: function (c) {
            var t = parseInt(new Date().getTime());
            if (c && typeof(c) == "number") {
                t = t + c;
            }
            return t;
        },
        //合并json对象,参数1是原始json,参数2是要合并的json,如果有重复,后者覆盖前者.
        jsonExt: function (_old, _new) {
            return $.extend({}, _old, _new);
        },
        //找到json对象中的某个key的值
        jsonFind: function (key,data) {
            if (key in data) {
                return data[key];
            } else {
                return false;
            }
        },
        formatJson: function (c, b) {
            var d = null, e = "", f = 0, a = "   ";
            b = b || {};
            b.newlineAfterColonIfBeforeBraceOrBracket = (b.newlineAfterColonIfBeforeBraceOrBracket === true) ? true : false;
            b.spaceAfterColon = (b.spaceAfterColon === false) ? false : true;
            if (typeof c !== "string") {
                c = JSON.stringify(c)
            } else {
                c = JSON.parse(c);
                c = JSON.stringify(c)
            }
            d = /([\{\}])/g;
            c = c.replace(d, "\r$1\r");
            d = /([\[\]])/g;
            c = c.replace(d, "\r$1\r");
            d = /(\,)/g;
            c = c.replace(d, "$1\r");
            d = /(\r\r)/g;
            c = c.replace(d, "\r");
            d = /\r\,/g;
            c = c.replace(d, ",");
            if (!b.newlineAfterColonIfBeforeBraceOrBracket) {
                d = /\:\r\{/g;
                c = c.replace(d, ":{");
                d = /\:\r\[/g;
                c = c.replace(d, ":[")
            }
            if (b.spaceAfterColon) {
                d = /\:/g;
                c = c.replace(d, ": ")
            }
            $.each(c.split("\r"), function (g, j) {
                var h = 0, k = 0, l = "";
                if (j.match(/\{$/) || j.match(/\[$/)) {
                    k = 1
                } else {
                    if (j.match(/\}/) || j.match(/\]/)) {
                        if (f !== 0) {
                            f -= 1
                        }
                    } else {
                        k = 0
                    }
                }
                for (h = 0; h < f; h++) {
                    l += a
                }
                e += l + j + "\r";
                f += k
            });
            return e
        },
        numberFormat: function (number, decimals, dec_point, thousands_sep) {
            /*
             * 参数说明：
             * number：要格式化的数字
             * decimals：保留几位小数
             * dec_point：小数点符号
             * thousands_sep：千分位符号
             * */
            number = (number + '').replace(/[^0-9+-Ee.]/g, '');
            var n = !isFinite(+number) ? 0 : +number,
                prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
                sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
                dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
                s = '',
                toFixedFix = function (n, prec) {
                    var k = Math.pow(10, prec);
                    return '' + Math.ceil(n * k) / k;
                };
            s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
            var re = /(-?\d+)(\d{3})/;
            while (re.test(s[0])) {
                s[0] = s[0].replace(re, "$1" + sep + "$2");
            }
            if ((s[1] || '').length < prec) {
                s[1] = s[1] || '';
                s[1] += new Array(prec - s[1].length + 1).join('0');
            }
            return s.join(dec);
        },
        printJson: function (_data) {
            return $api.jsonToStr(_data, 'printJson : ');
        },
        print: function (_data, _dataName) {
            if(_$.config.debug){
                var name = _dataName ? _dataName + '' : '打印 _$.tool.print :';
                var type = _$.tool.typeof(_data);

                if (type == 'string') {
                    console.log('\r\r' + name + '[' + type + '] => ' + _data + '\r\r');
                } else if (type == 'number' || type == 'date' || type == 'boolean') {
                    console.log('\r\r' + name + '[' + type + '] => ' + _data + '\r\r');
                } else if (type == 'array' || type == 'object') {
                    console.log('\r\r' + name + '[' + type + '] => ' + _$.tool.formatJson(_data) + '\r\r');
                } else {
                    console.log('\r\r' + name + '[' + type + '] => sorry , un print this type to log' + '\r\r');
                }
            }
        },
        dataEval: function (data) {
            try {
                return eval(data);
            } catch (e) {
                if (_$.config.debug)console.log('_$.tool.dataEval error : ' + data)
                return false;
            }
        },
        html_encode: function (str) {
            var s = "";
            if (str.length == 0) return "";
            s = str.replace(/&/g, "&gt;");
            s = s.replace(/</g, "&lt;");
            s = s.replace(/>/g, "&gt;");
            s = s.replace(/ /g, "&nbsp;");
            s = s.replace(/\'/g, "&#39;");
            s = s.replace(/\"/g, "&quot;");
            s = s.replace(/\n/g, "<br>");
            return s;
        },
        html_decode: function (str) {
            var s = "";
            if (str.length == 0) return "";
            s = str.replace(/&gt;/g, "&");
            s = s.replace(/&lt;/g, "<");
            s = s.replace(/&gt;/g, ">");
            s = s.replace(/&nbsp;/g, " ");
            s = s.replace(/&#39;/g, "\'");
            s = s.replace(/&quot;/g, "\"");
            s = s.replace(/<br>/g, "\n");
            return s;
        },
        test: function (k, v) {
            (function (regExps) {
                var t = k in regExps ? regExps[k] : false;
                if (!k && !v) {
                    return _$.language.dataTest.NULL;
                } else if (!t) {
                    return _$.language.dataTest.undefined;
                }
                var _v = v.replace(/^\s+|\s+$/g, "");
                var regExpString = new RegExp(_$.dataTest.regExps[k]);
                if (_$.config.debug) {
                    console.log('_$.dataTest.test: - 类型 :\t' + k);
                    console.log('_$.dataTest.test: - 值 :\t' + _v);
                    console.log('_$.dataTest.test: - 结果 :\t' + regExpString.test(_v));
                }
                return regExpString.test(_v);
            })({
                'CODE': "^\\d{" + _$.config.codeSize + "}$",//验证码
                'decmal': "^([+-]?)\\d*\\.\\d+$", //浮点数
                'decmal1': "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*$", //正浮点数
                'decmal2': "^-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*)$", //负浮点数
                'decmal3': "^-?([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0)$", //浮点数
                'decmal4': "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0$", //非负浮点数（正浮点数 + 0）
                'decmal5': "^(-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*))|0?.0+|0$", //非正浮点数（负浮点数 + 0）
                'intege': "^-?[1-9]\\d*$", //整数
                'intege1': "^[1-9]\\d*$", //正整数
                'intege2': "^-[1-9]\\d*$", //负整数
                'num': "^([+-]?)\\d*\\.?\\d+$", //数字
                'num1': "^[1-9]\\d*|0$", //正数（正整数 + 0）
                'num2': "^-[1-9]\\d*|0$", //负数（负整数 + 0）
                'ascii': "^[\\x00-\\xFF]+$", //仅ACSII字符
                'chinese': "^[\\u4e00-\\u9fa5]+$", //仅中文
                'color': "^[a-fA-F0-9]{6}$", //颜色
                'date': "^\\d{4}(\\-|\\/|\.)\\d{1,2}\\1\\d{1,2}$", //日期
                'year': "^\\d{4}$", //年份
                'month': "^(0?[[1-9]|1[0-2])$", //月份
                'day': "^(0?[[1-3]|1[0-9])$", //日子
                'email': "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", //邮件
                'idcard': "^[1-9]([0-9]{14}|[0-9]{17})$", //身份证
                'ip4': "^(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)$", //ip地址
                'letter': "^[A-Za-z]+$", //字母
                'letter_l': "^[a-z]+$", //小写字母
                'letter_u': "^[A-Z]+$", //大写字母
                'mobile': "^0?(13|14|15|16|17|18|19)[0-9]{9}$", //手机
                'mobile2': "^(1[3458])[0-9]{9}|((\+852|00852)[9|8|6|5])[0-9]{7}$", //支持香港手机号
                'tel1': "^(0[0-9]{2,3}\\-)?([2-9][0-9]{6,7})+(\\-[0-9]{1,4})?$", //固定电话
                'tel2': "^((0[0-9]{2,3}\-)?[2-9][0-9]{6,7}|((00852|\+852)\-)?([2-3][0-9]{7}))+(\-[0-9]{1,4})?$", //固定电话（支持香港固话）
                'notempty': "^\\S+$", //非空
                'password': "^.*[A-Za-z0-9\\w_-]+.*$", //密码
                'fullNumber': "^[0-9]+$", //数字
                'picture': "(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$", //图片
                'qq': "^[1-9]*[1-9][0-9]*$", //QQ号码
                'rar': "(.*)\\.(rar|zip|7zip|tgz)$", //压缩文件
                'tel': "^[0-9\-()（）]{7,18}$", //电话号码的函数(包括验证国内区号,国际区号,分机号)
                'url': "^http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$", //url
                'username': "^[A-Za-z0-9_\\-\\u4e00-\\u9fa5]+$", //用户名
                'zipcode': "^\\d{6}$", //邮编
                'realname': "^[A-Za-z\\u4e00-\\u9fa5]+$", // 真实姓名,
                'imgpach' : "(http\:\/\/|https\:\/\/)\w.*.(jpg|gif|png)"//http开头的图片地址
            })
        }
    }
    _$.user = {
        get:function(key,call){
            _$.user.init();
            if (_$.tool.typeof(key)!=='string'){
                _$.config.debug && console.log('_$.user.get(key,call) =>  error : key not is an string => type is :' + _$.tool.typeof(key));
                return false;
            }
            var data = _$.tool.jsonFind(key, user_data);
            _$.config.debug && _$.tool.print(user_data, 'get => ' + key + ' => ' + data);
            _$.user.call(data,call);
        },
        set: function (data,call) {
            _$.user.init();
            if (_$.tool.typeof(data)!=='object'){
                _$.config.debug && console.log('_$.user.set(data,call) =>  error : data not is an object => type is :' + _$.tool.typeof(data));
                return false;
            }
            user_data = _$.tool.jsonExt(user_data , data);
            $api.setStorage(_$.config.userDataName, user_data);
            _$.config.debug && _$.tool.print(user_data,'set => user_data:');
            _$.user.call(user_data,call);
        },
        clear: function (call) {//清空用户数据
            $api.rmStorage(_$.config.userDataName);
            _$.user.init(call);
        },
        init: function (call) {//初始化,或者刷新用户变量数据
            var _user_data = $api.getStorage(_$.config.userDataName);
            if (undefined == _user_data) {
                _$.config.debug && console.log('user_data is undefined , so... init the val');
                user_data = {
                    'token': 'unset'    //默认token
                }
                $api.setStorage(_$.config.userDataName, user_data);
            }else{
                if(_$.tool.typeof(_user_data)=='string'){
                    try{
                        _user_data = $api.strToJson(_user_data);
                    }catch (e){
                        _$.config.debug && console.log('user_data not is an object.');
                        return false;
                    }
                }
                user_data = _user_data;
            }
            _user_data = null;
            _$.user.call(user_data,call);
        },
        load: function (call) {//服务器端读取数据
            var option = {
                call: function (data) {
                    if (data.status == '200') {
                        _$.user.set(data.data,call);
                    }
                },
                data:{
                    do : 'apihome',
                    op : 'login'
                }
            }
            _$.ajax(option);
        },
        update: function (data,call) {
            var option = {
                action: _$.config.api_usersave,
                call: function (data) {
                    if (data.status == '200') {
                        _$.user.set(data.data,call);
                    }
                },
                data:data
            }
            _$.page.ajax(option);
        },
        login:function(){
            api.closeToWin({
                name:'root'
            })
        },
        call:function(data,call){
            if(_$.tool.typeof(call)=='function'){
                call(data);
            }
        }
    }
    _$.imgCache = {
        default:'',
        load:function(){
            //数据显示完成后调用此方法加载图片;
            try{
                var data = $('img.imgcache');
                for (var i = 0; i < data.length; i++) {
                    (function(index){
                        var imgUrl=data.eq(index).attr('data_url');
                        if(_$.config.imgCache){
                            api.imageCache({
                                url:imgUrl
                            }, function(ret, err) {
                                if(ret.status){
                                    data.eq(index).attr('src',ret.url).removeAttr('data_url').removeClass('imgcache');
                                }else if(!ret.status){
                                    data.eq(index).attr('src',ret.url);
                                    _$.config.debug && console.log('_$.cache(data,call) => argument['+ i + '] cache load faild. use argument baseurl : '+ data[i].url);
                                }else{
                                    _$.config.debug && console.log('_$.cache(data,call) err => : ' + $api.jsonToStr(err));
                                }
                                _$.config.debug && console.log(ret.status + ' / '+ret.url);
                            });
                        }else{
                            data.eq(index).attr('src',imgUrl).removeAttr('data_url').removeClass('imgcache');
                        }
                    })(i)
                }
            }catch (e){
                _$.config.debug && console.log(e);
            }
        },
        format:function(data){
            //格式化data数据，将所有img的data格式化成标准的json;
            var f_id = _$.tool.tempid();
            var index = 0;
            var img = '';
            function jsonArrayPre(data){
                for(var i in data){
                    var type = _$.tool.typeof(data[i]);
                    if(type=='string'){
                        data[i] = strPre(data[i]);
                    }else if(type=='object' && type=='array'){
                        data[i] = jsonArrayPre(data[i]);
                    }
                    return data;
                }
            }
            function strPre(str){
                index++;
                if(_$.tool.test('imgpach',str)){
                    var id = f_id + '_' + index;
                    _data.push({
                        id:id,
                        url:testObj[key]
                    });
                    return {
                        id:id,
                        src:img
                    }
                }
            }
            return jsonArrayPre(data,_data);
        }
    }
    _$.app = {
        close: function () {
            api.closeWin();
        },
        open_win:function(url,name,data){
            var link_url = url;
            var link_data = data;
            var link_name = name;
            if(link_url){
                var option = {
                    name: link_url,
                    url: '../root/page.html',
                    delay: 350,
                    reload:true,
                    pageParam: {
                        winName : api.winName,
                        frameName: api.frameName,
                        link_name:link_url,
                        link_url:link_url,
                        link_title:link_name?link_name:_$.config.appname_cn,
                        link_data:link_data
                    },
                    progress: {
                        type: "page"
                    }
                }
                _$.tool.print(option);
                api.openWin(option);
            }
        },
        statusBarHeight:function(){
            var sysType = api.systemType;
            var h = 0;
            if (sysType == 'ios') {
                var strSV = api.systemVersion;
                var numSV = parseInt(strSV, 10);
                var fullScreen = api.fullScreen;
                var iOS7StatusBarAppearance = api.iOS7StatusBarAppearance;
                if (numSV >= 7 && !fullScreen && iOS7StatusBarAppearance) {
                    return 20;
                }
            } else if (sysType == 'android') {
                var ver = api.systemVersion;
                ver = parseFloat(ver);
                if (ver >= 4.4) {
                    return 25;
                }
            }
        },
        head: function (arr) {

            page_log.h = _$.app.statusBarHeight();
            _$.config.debug && console.log('_$.app.head '+_$.tool.typeof(arr)+' : =>' + arr + '<=');
            /**
             * [name,rightBtn,leftBtn,act]
             * rightBtn[string] && leftBtn[string] = icon:xxxx  &  text:xxxx  & img:<img src="xxxx" ...>
             **/
            var setting = arr&& _$.tool.typeof(arr)=='array' ? arr : [];
            if(_$.config.debug)console.log(setting[0] + ' / ' + setting[1] + ' / ' + setting[2])
            var l='',r='',n = [];
            var page_name = setting[0] ? setting[0] : _$.config.appname_cn;
            function formatHead(subStr) {
                n = (subStr && subStr.indexOf(':') != -1) ? subStr.split(':',2) : ['hide', ''];
                if(n[0]=='icon'){
                    n[0]=n[1];
                    n[1]='';
                } else if (n[0] == 'text') {
                    n[0]='icon_'+n[0];
                } else if (n[0] == 'img'){
                    n[0]='icon_'+n[0];
                    n[1] = subStr.split('img:')[1]
                } else {
                    return false;
                }
            }
            if (setting[1]) {
                formatHead(setting[1]);
                r = '<span class="icon ' + n[0] + ' nav_r">' + n[1] + '</span>';
            }

            if (setting[2]) {
                formatHead(setting[2]);
                l = '<span class="icon ' + n[0] + ' nav_l">' + n[1] + '</span>';
            } else if(page_data.link_type!='unback'){
                l = '<span class="icon icon_back nav_l" onclick="_$.app.close()"></span>';
            }

            var html = '<header class="app_head" style="border-top:'+page_log.h+'px transparent solid;">' + l + r + '<h1 class="page_name">' + page_name + '</h1>' + '</header>';

            if(page_log.header!=true){
                page_log.header=true;
                console.log(html);
                $('#'+_$.config.wrapid).prepend(html);
            }
        },
        quit: function () {
            api.closeWin({
                name: 'root'
            });
        },
        reset: function () {
            api.rebootApp();
        },
        reload:function(){
            window.location.reload();
        },
        showInfo: function () {
            var string = arguments[0] ? arguments[0] : _$.language.dialog.msgInto.cont;
            api.toast({
                msg: string,
                duration: _$.config.msgTimeout,
                location: 'bottom'
            });
        },
        showAlert: function (confirmText, confirmTitle, confirmButton, call) {
            api.alert({
                msg: confirmText ? confirmText : _$.language.dialog.alert.title,
                title: confirmTitle ? confirmTitle : _$.language.dialog.alert.cont,
                buttons: [confirmButton ? confirmButton : _$.language.dialog.alert.button]
            }, function (ret, err) {
                if (ret && call) {
                    call();
                }
            });
        },
        showConfirm: function (confirmText, confirmTitle, confirmButton, call) {
            api.confirm({
                msg: confirmText ? confirmText : _$.language.dialog.confirm.title,
                title: confirmTitle ? confirmTitle : _$.language.dialog.confirm.cont,
                buttons: confirmButton ? confirmButton : _$.language.dialog.confirm.button
            }, function (ret, err) {
                if (ret && ret.buttonIndex == 1 && call) {
                    call(ret);
                } else if (err) {
                    _$.app.showInfo(err.message);
                }
            });
        },
        imgCall: function (data, option) {
            var FNImageClip = api.require('FNImageClip');
            if (_$.config.debug){
                _$.tool.print(option);
                _$.tool.print(data);
            }
            var localUrl = data.url;
            var ajaxSetting = {//合并所有ajax的参数
                values:{
                    do :'apijin',
                    op :'pic'
                },
                files: data.url,
                call:function(data){
                    if(option.call){
                        data.data.localUrl = localUrl;
                        option.call(data);
                    }
                }
            }

            if (data.url == '' ) {
                if(_$.config.debug ){
                    console.log('选择图片,没有图片的数据,url和base64');
                }
                return;
            }
            _$.ajax(ajaxSetting);
        },
        getCamera: function (option) {
            api.getPicture({
                sourceType: 'camera',
                encodingType: 'jpg',
                mediaValue: 'pic',
                destinationType: option.type ? option.type : 'url',
                allowEdit: false,
                quality: 60,
                targetWidth: 800,
                targetHeight: 800,
                saveToPhotoAlbum: false
            }, function (ret, err) {
                if (ret) {
                    if (_$.config.debug)console.log('getCamera >>> ' + _$.tool.printJson(ret));
                    var data = {
                        url:ret.data
                    };
                    _$.app.imgCall(data, option);
                } else {
                    _$.app.showInfo(err.message);
                }
            });
        },
        galleryImg: function (option) {
            api.getPicture({
                sourceType: 'album',
                encodingType: 'jpg',
                mediaValue: 'pic',
                destinationType: option.type ? option.type : 'url',
                allowEdit: false,
                quality: 60,
                targetWidth: 800,
                targetHeight: 800,
                saveToPhotoAlbum: false
            }, function (ret, err) {
                if (ret) {
                    if (_$.config.debug)console.log('galleryImg >>> ' + _$.tool.printJson(ret));
                    var data = {
                        url:ret.data
                    };
                    _$.app.imgCall(data, option);
                } else {
                    _$.app.showInfo(err.message);
                }
            });
        },
        getImg: function (option) {
            //option={
            //    call:function
            //}
            if(_$.config.debug){
                console.log(_$.tool.printJson(option))
            };
            api.actionSheet({
                cancelTitle: '取消',
                buttons: ['拍照', '相册']
            }, function (ret, err) {
                if (ret.buttonIndex == 1) {
                    _$.app.getCamera(option);
                } else if (ret.buttonIndex == 2) {
                    _$.app.galleryImg(option);
                } else {
                    return;
                }
            });
        },
        viewImg: function (data) {
            for(var i in data){
                var s = data[i];
                if (s.indexOf('http://') != 0 && s.indexOf('https://') != 0) {
                    data[i] = _$.config.imgpach + s;
                }
            }
            var option = {
                name: 'img_view',
                url: '../code/img_view.html',
                delay: 150,
                bgColor:'rgba(255,255,255,0)',
                pageParam: {
                    img_data:data
                }
            }
            api.openWin(option);
        },
        sendMsg:function(number,text,call){
            api.sms({
                numbers: _$.tool.typeof(number)=='array'?number:[number],
                text: text
            },function(ret, err){
                if(ret && ret.status){
                    if(ret&&call)call()
                }
            });
        },
        clearCache: function () {
            api.clearCache(function () {
                _$.app.showInfo('缓存已清除…');
            })
        },
        netInfo: function () {
            if (api.connectionType == 'none') {
                return false;
            } else {
                return api.connectionType;
            }
        }
    }
    _$.debug_tool=function(){
        api.actionSheet({
            title: '开发调试菜单',
            cancelTitle: '取消',
            buttons: ['刷新页面', '输出调试信息','清空user数据', '清除缓存', 'MENU']
        }, function (ret, err) {
            var index = ret.buttonIndex;
            if (index == 1) {
                window.location.reload();
            } else if (index == 2) {
                var str = '' +
                    '\r\r\r\r 调试信息 \r ' +
                    '--------------------------- api ---------------------------------\r' +
                    _$.tool.formatJson(api) +
                    // '--------------------------- _$ ----------------------------------' +
                    // _$.tool.formatJson(_$) +
                    '--------------------------- user_data ---------------------------\r' +
                    _$.tool.formatJson(user_data) +
                    '----------------------------------------------------------------- \r\r\r\r'
                console.log(str);
            } else if (index == 3) {
                _$.user.clear();
                api.toast({
                    msg: '清除了用户数据'
                })
            }  else if (index == 4) {
                api.clearCache(function () {
                    api.toast({
                        msg: '清除了缓存'
                    });
                });
            } else if (index == 5) {
                api.openWin({
                    name:'menu',
                    url:'http://www.adot365.com/addons/grow/template/mobile/api/html/root/menu.html'
                })
            }
        });
    }
    _$.ajax = function (option) {
        /**
         * 对ajax请求进行延时执行,已相应input&textaela的焦点移除
         * option={
         *      call:function,
         *      values:{
         *          data1:data1,
         *      ……
         *      },
         *      files:{
         *          ……
         *      }
         * }
         */
        $('input,textarea').blur();

        if (!_$.app.netInfo()) {//检查网络
            _$.app.showInfo('网络出错,请检查您的手机是否联网.');
            return false;
        }
        //初始化ajax参数默认值
        var config = {//ajax的默认设置
            call: function (data,call) {
                if (_$.tool.typeof(option.call) == 'function'){
                    option.call(data);
                }
                if(call && call.imagecache){
                    _$.imgCache.load();
                }
            },
            data: {
                values:{},
                files:{}
            }

        }
        if (option.values) {
            config.data.values = option.values
        }
        if (option.files) {
            if (_$.tool.typeof(option.files) == 'array' || _$.tool.typeof(option.files) == 'string') {
                config.data.files.file = option.files;
            }else{
                console.log(_$.tool.typeof(option.files));
            }
        }

        _$.user.get('token',function(token){
            try{
                config.data.values.auth = {
                    token:token,
                    deviceId:api.deviceId,
                    deviceTime:_$.tool.time()
                }
            }catch (e){
                _$.tool.print(e, '_$.ajax => _$.user.get("token".... error : ');
                return false;
            }
        });

        var ajaxSetting = {//合并所有ajax的参数
            url: _$.config.apiurl,
            data: config.data,
            dataType: option.dataType ? option.dataType : _$.config.ajaxdatatype,
            method: _$.config.ajaxtype,
            timeout: _$.config.ajaxtimeout,
            cache: false,
            imagecache:_$.config.imgCache
        }
        //输出调试信息
        if (_$.config.debug) {
            console.log('\r\r vvvvvvvvvvvvvvvvvvvv ajax option & Setting vvvvvvvvvvvvvvvvvvvv \r\r[ win:' + api.winName + (api.frameName == '' ? ' ]\r' : (' - frame:' + api.frameName + ' ]\r')) + _$.tool.formatJson(option) +'\r ------------------------------------- \r'+ _$.tool.formatJson(ajaxSetting) + ' \r ^^^^^^^^^^^^^^^^^^^^ ajax option & Setting ^^^^^^^^^^^^^^^^^^^^ \r');
        }
        api.ajax(ajaxSetting, function (ret, err) {
            if(ret){
                if (_$.tool.typeof(ret) == 'string') {
                    ret = $api.strToJson(ret);
                }
                ret.CONST={
                    DEFAULT_IMG:_$.imgCache.default,
                    IMG_CACHE:ajaxSetting.imagecache
                }
                if(ret.status=='301'){
                    _$.user.clear(function(){
                        _$.user.login();
                    })
                    return false;
                }
                config.call(ret,ajaxSetting);
            } else if (err) {
                _$.app.showInfo('未能正确得到数据,请联系管理员');
            }
        });
        return false;
    }
    window._$ = _$;
    _$.user.init();
    _$.config.hilight ? api.setStatusBarStyle({style: 'light'}) : 0;
    page_data.headclick=function(){}
    $('body').attr('id',_$.config.wrapid);
    $('#' + _$.config.wrapid).on('click', '.link,.applink', function () {
        if (_$.config.debug)console.log('.link被点击');
        var _self = $(this),
          link_url = _self.attr('link_url'),
          link_name = _self.attr('link_name'),
          link_title = _self.attr('link_title'),
          link_data = _self.attr('link_data'),
          link_type = _self.attr('link_type'),
          link_headbtn = _self.attr('link_headbtn');
        if (link_url) {
            var page_data = {
                link_name: link_url,
                link_title: link_title,
                link_headbtn: link_headbtn,
                link_url: link_url,
                link_type: link_type,
                link_data: link_data ? eval('(' + link_data + ')') : undefined
            };
            if (api.frameName) {
                page_data.frameName = api.frameName;
            }
            if (api.winName) {
                page_data.winName = api.winName;
            }
            page_data.parentParam = api.pageParam;
            var option = {
                name: link_url,
                url: '../root/page.html',
                delay: 350,
                slidBackEnabled: link_type == 'unback' ? false : true,
                reload:true,
                pageParam: page_data,
                progress: {
                    type: "page"
                }
            }
            _$.tool.print(option);
            api.openWin(option);
        } else {
            if (_$.config.debug)console.log('!link_url');
        }
    })
    try {
        pageready();
        api.addEventListener({
            name: 'longpress'
        }, function (ret, err) {
            if(_$.config.debugtools && api.winName!=='root'){
                _$.debug_tool();
            }
        });
    } catch (e) {
        console.log(e);
        alert(e);
    }
}
